#ifndef GIGEDEVICEOBJECT_H
#define GIGEDEVICEOBJECT_H

#include "detectorobject.h"
#include "Windows.h"
#include "MVC_Common.h"
class GigeCcdIntf;

class GigEDeviceObject : public DetectorObject
{
    Q_OBJECT
public:
    explicit GigEDeviceObject(QObject *parent = 0);
    ~GigEDeviceObject() { freeDetector(); }

    void setGainCorrect(GainCorrect gc) { gainType = gc; }
    void setImageReadyGigE(ushort cardNo, const MVCFRAMEINFO &frame);
    void setDevLostedGigE(ushort cardNo, ulong devStat) { emit devLostedGigE(cardNo, devStat); }

signals:
    void imageReadyGigE(ushort cardNo);
    void devLostedGigE(ushort cardNo, ulong devStat);

public slots:
    void initDetector();
    void freeDetector();
    void startCapture(bool start);

protected slots:
    void onImageReadyGigE(ushort cardNo);
    void onDevLostedGigE(ushort cardNo, ulong devStat);

protected:
    static uint __stdcall StreamProc(ushort cardNo, MVCFRAMEINFO frame, void *pData);
    static uint __stdcall DevLostProc(ushort cardNo, ulong devStat, void *pData);

private:
    int devConnected;
    bool devLosted;
    bool firstRun;

    ushort *frameBuf;
    float *darkBuf;
    float *gain30Buf;
    float *gain60Buf;
    GainCorrect gainType;

    GigeCcdIntf *intf;
};

#endif // GIGEDEVICEOBJECT_H
